"use strict";

import { request, summary, tags} from "../swagger";


import { responseWrapper } from "../helper/util";
import { Method, launch } from "./httpGet";

const tag = tags(["设备"]);
const SonicToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsic2hpeGluZyIsIjk5NzVjZmFkLTUzNTYtNGVlMS05YjI1LWEyZjgzMDgwMzI0NyJdLCJleHAiOjE3NjcxNTAwOTR9.GnJxWjH9dsselORyhjKjGQ804QYKN75AQimBZFQ-H6Y'

module.exports = class DevicesRouter {
  @request("get", "/api/devices/getAll")
  @summary("获取sonic当前设备列表")
  @tag
  static async getAll(ctx, next) {
    var user = ctx.state.user.data;
    var devices = await launch(Method.GET, '/server/api/controller/devices/list?page=1&pageSize=100', null, 'http://192.168.58.53:8082', { SonicToken })
    var agentslist = await launch(Method.GET, '/server/api/controller/agents/list', null, 'http://192.168.58.53:8082', { SonicToken })
    console.log(devices,agentslist)
    if (devices.code && agentslist.code){
      ctx.body = responseWrapper({devices:devices.data,agentslist:agentslist.data});
    }
  }

  // @request("get", "/api/devcies/install")
  // @summary("向设备安装")
  // @query({
  //   platform: { type: "string", default: "android", description: "平台" },
  //   agentKey: { type: "string", default: "", description: "agentKey" },
  //   deviceName: { type: "string", default: "", description: "设备名" },
  //   host:{ type: "string", default: "", description: "设备" },
  // })
  // @tag
  // static async getAll(ctx, next) {
  //   const {platform,agentKey,deviceName,uuid} = ctx.query
  //   // var page = ctx.query.page || 0;
  //   // var size = ctx.query.size || 10;
  //   var user = ctx.state.user.data;
  //   // var devices = await launch(Method.GET, '/server/api/controller/devices/list?page=1&pageSize=100', null, 'http://116.62.108.113:8082', { SonicToken })
  //   // var agentslist = await launch(Method.GET, '/server/api/controller/agents/list', null, 'http://116.62.108.113:8082', { SonicToken })
  //   if (devices.code && agentslist.code){
  //     ctx.body = responseWrapper({devices:devices.data,agentslist:agentslist.data});
  //   }
  // }
}